﻿using SqlSugar;
using static DataModels.Enums.GeneralEnum;

namespace DataModels.Entities.AuthCore
{
    /// <summary>
    /// 用户收货地址表
    /// </summary>
    [SugarTable]
    public class DeliveryAddress
    {
        /// <summary>
        /// 地址ID
        /// </summary>
        [SugarColumn(IsPrimaryKey = true)]
        public Guid UUID { get; set; } = Guid.NewGuid();

        /// <summary>
        /// 用户ID
        /// </summary>
        public Guid UserUUID { get; set; }

        /// <summary>
        /// 收货人姓名
        /// </summary>
        public string ContactPerson { get; set; }

        /// <summary>
        /// 联系电话
        /// </summary>
        public string ContactPhone { get; set; }

        /// <summary>
        /// 省份/州
        /// </summary>
        public string Province { get; set; }

        /// <summary>
        /// 城市
        /// </summary>
        public string City { get; set; }

        /// <summary>
        /// 区县
        /// </summary>
        public string District { get; set; }

        /// <summary>
        /// 详细地址
        /// </summary>
        public string AddressDetail { get; set; }

        /// <summary>
        /// 邮政编码
        /// </summary>
        public string ZipCode { get; set; }

        /// <summary>
        /// 是否默认地址
        /// </summary>
        public Status IsDefault { get; set; } = Status.Disable;

        /// <summary>
        /// 地址标签（家、公司、学校等）
        /// </summary>
        public string AddressTag { get; set; }

        /// <summary>
        /// 经度
        /// </summary>
        public decimal? Longitude { get; set; }

        /// <summary>
        /// 纬度
        /// </summary>
        public decimal? Latitude { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTime { get; set; } = DateTime.Now;

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }

        /// <summary>
        /// 删除标记
        /// </summary>
        public Status IsDeleted { get; set; } = Status.Disable;

        /// <summary>
        /// 获取完整拼接地址（包含省市区）
        /// </summary>
        public string GetFullAddress()
        {
            return $"{Province}{City}{District}{AddressDetail}";
        }

        /// <summary>
        /// 获取简洁拼接地址（不包含省市区，仅详细地址）
        /// </summary>
        public string GetSimpleAddress()
        {
            return AddressDetail;
        }
    }
}
